    .syntax unified
    .cpu cortex-m3
    .fpu softvfp
    .thumb

.global get_context
get_context:
    stmia r0, {r0-r11}  //把r0-r11寄存器存储到r0(参数0)所指向的内存
    str sp, [r0, #48]   //把sp寄存器存储到r0偏移48的内存
    str lr, [r0, #52]
    str r12, [r0, #56]
    str lr, [r0, #60]   //同上...

    mov r0, #0          //设置返回值为0
    mov pc, lr          //返回调用地址

.global set_context
set_context:
    mov r12, r0         //把参数0复制到r12寄存器
    ldmia r12, {r0-r11} //从r12指向的内存恢复r0-r11寄存器
    ldr sp, [r12, #48]  //从偏移48的内存恢复sp寄存器
    ldr lr, [r12, #52]  //同上
    add r12, r12, #56   //把基地址偏移56后重新放回r12寄存器
    ldmia r12, {r12, pc}    //一次性把r12和pc寄存器给恢复了(在保存时，r12和pc在内存上时连续的)

.global swap_context
swap_context:
    stmia r0, {r0-r11}
    str sp, [r0, #48]
    str lr, [r0, #52]
    str r12, [r0, #56]
    str lr, [r0, #60]

    mov r12, r1
    ldmia r12, {r0-r11}
    ldr sp, [r12, #48]
    ldr lr, [r12, #52]
    add r12, r12, #56
    ldmia r12, {r12, pc}
